package com.doctor.database.service;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.doctor.database.dao.BaseDao;
import com.doctor.database.model.Account;
import com.doctor.database.repository.AccountRepository;
import com.doctor.utils.ResponseUtil;
import com.doctor.web.controller.AccountController;

@Service("accountService")
public class AccountService {
	private static final Logger LOGGER = Logger
			.getLogger(AccountService.class);
	@Autowired
	AccountRepository accountRepository;
	
	@Autowired
	BaseDao dao;

	@Transactional
	public Map<String , Object> findAccountByNameAndPwd(String name,String pwd){
		Map<String , Object> resultMap = new HashMap<String , Object>();
		Account account=accountRepository.findByNameAndPwd(name, pwd);
		if(account !=null){
			resultMap.put("returnCode", 1);
			resultMap.put("returnMessage", "登陆成功!");
			resultMap.put("data", ResponseUtil.ObjectToList(account));
		}else{
			resultMap.put("returnCode", 0);
			resultMap.put("returnMessage", "用户名或者密码错误!");
		}
		return resultMap;
	}
	
}
